package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.domain.db.SurveyDetails;
import com.tanhua.dubbo.api.db.PaperApi;
import com.tanhua.dubbo.mapper.SurveyDetailsMapper;
import org.apache.dubbo.config.annotation.Service;

/**
 * 试卷api实现类
 * @author Huo
 * @date 2021/07/17 17:07:24
 */
@Service
public class PaperApiImpl implements PaperApi {

    private final SurveyDetailsMapper surveyDetailsMapper;

    public PaperApiImpl(SurveyDetailsMapper surveyDetailsMapper) {
        this.surveyDetailsMapper = surveyDetailsMapper;
    }

    @Override
    public Page<SurveyDetails> queryPaper(Integer page, Integer pageSize) {
        Page<SurveyDetails> ipage = new Page<>(page,pageSize);
        return (Page<SurveyDetails>) surveyDetailsMapper.selectPage(ipage,null);
    }

    @Override
    public void savePaper(SurveyDetails surveyDetails) {
        surveyDetailsMapper.insert(surveyDetails);
    }

    @Override
    public SurveyDetails queryPaperById(Integer paperId) {
        return surveyDetailsMapper.selectById(paperId);
    }

    @Override
    public void update(SurveyDetails surveyDetails) {
        surveyDetailsMapper.updateById(surveyDetails);
    }

    @Override
    public void delete(Integer paperId) {
        surveyDetailsMapper.deleteById(paperId);
    }
}
